package com.one.rope.mvp.web.common.jwt;

/**
 * @author Weijian.liu
 * @desc 认证Token状态枚举
 * @date 2018/12/12
 */
public enum TokenState {

  /**
   * 过期
   */
  EXPIRED("EXPIRED"),
  /**
   * 无效(token不合法)
   */
  INVALID("INVALID"),
  /**
   * 有效的
   */
  VALID("VALID");

  private String state;

  private TokenState(String state) {
    this.state = state;
  }

  /**
   * 根据状态字符串获取token状态枚举对象
   */
  public static TokenState getTokenState(String tokenState) {
    TokenState[] states = TokenState.values();
    TokenState ts = null;
    for (TokenState state : states) {
      if (state.toString().equals(tokenState)) {
        ts = state;
        break;
      }
    }
    return ts;
  }

  public String toString() {
    return this.state;
  }

  public String getState() {
    return state;
  }

  public void setState(String state) {
    this.state = state;
  }

}
